import { NextRequest, NextResponse } from 'next/server'
import { aiClient, type ChatRequest } from '@/ai/index'


export async function POST(request: NextRequest) {
    console.log('request',request)
    if (!request) {
        return NextResponse.json({ error: '缺少查询参数' }, { status: 400 })
    }
    try {
        const result = await aiClient.generate({
            model: 'qwen-max',
            messages: [
                { role: 'system', content: '你是一个专业的翻译者，你需要将输入的英文翻译成中文。' },
                { role: 'user', content: 'hello world' }
            ],
            stream: true,
            temperature: 0.7,
            max_tokens: 1024
        })

        return NextResponse.json({ result }); // 返回 JSON 响应
    } catch (error: any) {
        console.error('API error:', error);
        return NextResponse.json({ error: error.message }, { status: 500 });
    }
}